
struct TOVERLAP : public OVERLAPPED
{
	static void Free(HANDLE);

	BOOL m_bResult;

	explicit TOVERLAP(DWORD aval) : m_bResult(0)
	{
		::memset(this, 0, sizeof(OVERLAPPED));
		Offset = aval;
	}

	TOVERLAP() //	for container
	{
		::memset(this, 0, sizeof(OVERLAPPED));
	}
	TOVERLAP(const TOVERLAP & aval) //	for container
	{
		::memcpy(this, & aval, sizeof(OVERLAPPED));
	}

 inline ~TOVERLAP() { Free(hEvent); }

 inline DWORD getCode() { return Internal; }
	bool testResult(HANDLE afile, BOOL bWait = FALSE)
	{
		if (m_bResult) return true;
		DWORD thenum(0);
		m_bResult = ::GetOverlappedResult( afile, this, & thenum, bWait );
		if (m_bResult && thenum) return true;
		{
			Internal = ::GetLastError();
			if (!Internal) Internal = ERROR_WRITE_FAULT;
		}
		return false;
	}
};

void CreateBitmapInfoStruct(const BITMAP & bmp, PBITMAPINFO pbmi);
HRESULT CreateBMPFile(HANDLE afile, PBITMAPINFO pbi, HBITMAP hBMP, HDC);
bool NotAtlGetErrorDescription(DWORD acode, LPCWSTR acontext, BSTR * );
bool cutTopLeft(LPPOINT psize, LPPOINT poffset);
